<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<link rel="stylesheet" type="text/css" href="../public/css/index.css" />
		<title>昆山健康网</title>
		<style type="text/css">
			body {
				background: #f9f9f9;
			}
		</style>
	</head>
	<body>
		<div id="example">
			<div class="index_header">
				<div class="index_header_search">
					<div class="ihs_s_box">
						<input v-model="search" type="text" placeholder="点击搜索" class="ihs_s_boxI">
						<i class="ihs_s_boxIcon" @click="Search">
							<img style="width: 100%;" src="../public/images/icon/1_06.png" >
						</i>
					</div>
					<a href="/xlzxapi/wx_uCenter" class="ihs_UC">
						<img src="../public/images/icon/1_03.png" style="width:100%;" >
					</a>
				</div>
				
			</div>
			<div v-if="dataObj.length==0" style="text-align: center;color:#666;font-size: 1rem;display:block">
				<p>抱歉，没有查询到信息</p>
			</div>
			<div class="zxLists" v-if="dataObj.length>0">
				<a v-for="item,index in dataObj" :key="item.Id"  class="zxList" :href="'detail.html?id='+item.Id+'&title=详情'">
					<div class="zxListTitle textOver">
						{{item.FullHead}}
					</div>
					<div class="zxListIcon">
						<div class="zxListIconTime">
							<i></i>{{formatDate(item.FabuDate)}}
						</div>
						<div class="zxListIconLy textOver" v-show="item.ParentName">
							<i></i>{{item.ParentName}}
						</div>
						<i class="zxListDetail"></i>
						<div style="clear: both;float: none;"></div>
					</div>
				</a>

			</div>
		</div>

		<script src="../public/script/plug/jquery-3.3.1.min.js"></script>
		<script src="../public/script/plug/vue.js"></script>
		<script src="../public/script/plug/common.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" src="../public/script/plug/layer/layer.js"></script>
		<script>
			function getUrl() {
				let url = decodeURI(location.href).split('?')[1];
				if (url) {
					let obj = {};
					let u = url.split('&');
					for (let i in u) {
						obj[u[i].split('=')[0]] = u[i].split('=')[1];
					}
					return obj;
				} else {
					return false;
				}
			}
			
			
			
			let objUrl = getUrl();
			if (objUrl && objUrl.title) {
				document.title = objUrl.title;
			} else {
				document.title = '详情';
			}

			var data = {
				rows: 10,
				page: 1,
				search:objUrl.keyword || '',
				obj: {}, //当前分类总数据
				objRq: {}, //当前二级分类id url 信息
				dataObj: []
			};
			var vm = new Vue({
				el: '#example',
				data: data,
				mounted() {
					this.autoPage();
					window.addEventListener('scroll', this.handleScroll)
				},
				methods: {
					formatDate(time) {
						return formatDate(time, 'yyyy-MM-dd')
					}, //时间处理
					handleScroll: function(el) {
						if($(window).scrollTop()+$(window).height()>=$(document).height()){
							this.page=this.page+=1;
							this.getDate(this);
						}
					}, //滚动监听
					autoPage: function() {
						let that = this;
						this.page=1;
						this.getDate(this);
						
					}, //初始化参数
					getDate: function(that) {
						let da = {};
						da.rows = that.rows;
						da.page = that.page;
						da.keyword=that.search;
						$.ajax({
							url: '/home/searchlist2',
							type: 'post',
							data: da,
							success: function (d) {
								if (that.page > 1) {
									if (d.rt) {
										that.dataObj = that.dataObj.concat(d.rt);
									} else {
										that.dataObj = that.dataObj.concat(d.rows);
									}
								} else {
									if (d.rt) {
										that.dataObj = d.rt;
									} else {
										that.dataObj = d.rows;
									}
								}
						    }
						})
					}, //获取数据
					Search:function(){
						if(!this.search){
							layer.msg('请输入您需要搜索的内容');
						}else{
							let that = this;
							this.page=1;
							//window.location.search='keyword='+this.search;
							this.getDate(this);
							
							//执行搜索
						}
						
					},
					tabHeader: function(event) {
						let index = event.target.dataset.index;
						if (index == this.dataIndex) {
							return false;
						} else {
							this.dataIndex = index;
							this.page = 1;
							if (index == 0) {
								this.objRq = this.obj;
							} else {
								this.objRq = this.obj.child[index];
							}
							if(this.objRq.link){
								window.location.href=this.objRq.link;
								return false;
							}
							this.getDate(this);

						}
					}, //切换数据
				}
			});
		</script>

	</body>
</html>
